package com.ruoyi.electricity.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.electricity.domain.TRiskWarnings;
import com.ruoyi.electricity.service.ITRiskWarningsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 风险预警管理Controller
 * 
 * @author wu
 * @date 2023-10-28
 */
@RestController
@RequestMapping("/zdzh/warnings")
public class TRiskWarningsController extends BaseController
{
    @Autowired
    private ITRiskWarningsService tRiskWarningsService;

    /**
     * 查询风险预警管理列表
     */
    //@PreAuthorize("@ss.hasPermi('zdzh:warnings:list')")
    @GetMapping("/list")
    public TableDataInfo list(TRiskWarnings tRiskWarnings)
    {
        startPage();
        List<TRiskWarnings> list = tRiskWarningsService.selectTRiskWarningsList(tRiskWarnings);
        return getDataTable(list);
    }

    /**
     * 导出风险预警管理列表
     */
    //@PreAuthorize("@ss.hasPermi('zdzh:warnings:export')")
    @Log(title = "风险预警管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TRiskWarnings tRiskWarnings)
    {
        List<TRiskWarnings> list = tRiskWarningsService.selectTRiskWarningsList(tRiskWarnings);
        ExcelUtil<TRiskWarnings> util = new ExcelUtil<TRiskWarnings>(TRiskWarnings.class);
        return util.exportExcel(list, "warnings");
    }

    /**
     * 获取风险预警管理详细信息
     */
    //@PreAuthorize("@ss.hasPermi('zdzh:warnings:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tRiskWarningsService.selectTRiskWarningsById(id));
    }

    /**
     * 新增风险预警管理
     */
    //@PreAuthorize("@ss.hasPermi('zdzh:warnings:add')")
    @Log(title = "风险预警管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TRiskWarnings tRiskWarnings)
    {
        return toAjax(tRiskWarningsService.insertTRiskWarnings(tRiskWarnings));
    }

    /**
     * 修改风险预警管理
     */
    //@PreAuthorize("@ss.hasPermi('zdzh:warnings:edit')")
    @Log(title = "风险预警管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TRiskWarnings tRiskWarnings)
    {
        return toAjax(tRiskWarningsService.updateTRiskWarnings(tRiskWarnings));
    }

    /**
     * 删除风险预警管理
     */
    //@PreAuthorize("@ss.hasPermi('zdzh:warnings:remove')")
    @Log(title = "风险预警管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tRiskWarningsService.deleteTRiskWarningsByIds(ids));
    }
}
